<?php $__env->startSection('title','教学建设上传-Excel方式'); ?>
<?php $__env->startSection('css'); ?>
<link href="<?php echo e(asset(getThemeAssets('css/toastr.min.css'))); ?>" rel="stylesheet">
<style type="text/css">
    .widget .row span{
      font-size: 15px;
      font-weight: bold;
    }
    .p-md{
        padding-top: 6px;
        padding-bottom: 0px;
        margin-top: 0px;
        margin-bottom: 30px;
    }
    .m-b-md{
        padding-top: 3px;
    }
    .page-heading{
        padding-bottom: 2px;
    }
    .alert{
        /*padding-bottom: 0px;*/
        padding-left: 23px;
        padding-right: 23px;
        margin-bottom: 0px;
    }
    .alert p{
        font-size: 14px;
        font-weight: 12px;
    }
    .alert a{
        text-decoration: underline;
    }
    .canceled{
        margin: 0;
        padding: 0;
    }
    #login-form {
        margin-top: 30px;
    }
    #login-form img{
        width: 100%;
        margin-left: 0;
    }
    #footerrow {
      margin-top: 100px;
    }
    .col-sm-6 {
      padding: 3px;
    }
</style>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('content'); ?>

<div class="row wrapper border-bottom page-heading">
  <div class="col-sm-10">
    <h2><?php echo trans('upload.ConstructionTitle'); ?>-Excel</h2>
    <ol class="breadcrumb">
        <li>
            <a href="<?php echo e(url('admin')); ?>"><?php echo trans('home.title'); ?></a>
        </li>
        <li class="active">
            <a href="<?php echo e(url('/admin/upload')); ?>"><?php echo trans('upload.title'); ?></a>
        </li>
        <li class="active">
            <strong><?php echo trans('upload.ConstructionTitle'); ?></strong>
        </ConstructionTitle>
    </ol>
  </div>
  <div class="col-sm-2">
    <div class="title-action">
      <a class="btn btn-white" href="<?php echo e(url('/admin/constructionupload')); ?>"><i class="fa fa-reply"></i>  <?php echo trans('common.cancel'); ?>单条记录上传</a>
    </div>
  </div>
</div>
<div id="login-form">
    <div class="logo">
        <img id="logo" src="<?php echo e(asset(getThemeAssets('img/logo2.png'))); ?>">
    </div>
    <div class="row">
    <div class="col-lg-6 col-lg-offset-3">
        <div class="input-group">
          <div class="input-group-addon">
            <span class="glyphicon glyphicon-volume-up"></span>
          </div>
            <div class="alert alert-info">
              <p>1、教学建设 Excel模板请到<strong><a href="<?php echo e(url('/admin')); ?>">首页</a></strong>下载。 
              <p>2、请使用 <bold> Office 2010 </bold>   及以上版本，并严格按照最新模板的格式进行填写，保存后在此页面进行上传。</p>
            </div>  
        </div>
      <form class="form-horizontal" id="awardinfo" enctype="multipart/form-data" method="" action="">
      <?php echo e(csrf_field()); ?>

        <div class="form-group">
          <div class="input-group">
            <div class="input-group-addon">
              <span class="glyphicon glyphicon-tag"></span>
            </div>
            <input type="file" class="form-control" accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" id="uploadimg" name="awardimg" multiple />
          </div>
        </div>
        <div class="form-group">
          <div class="col-sm-12 ">
                <button type="button" id="submitbtn" class="btn btn-primary btn-block">确认提交</button>
          </div>
        </div>
      </form>
    </div>
  </div>
</div>
                        

<?php $__env->stopSection(); ?>
<?php $__env->startSection('js'); ?>
<script src="<?php echo e(asset(getThemeAssets('js/toastr.min.js'))); ?>"></script>
<script type="text/javascript">
    $(document).ready(function()  {
        $("#uploadimg").change(function() {
            var file;
            // 循环遍历用户选择的文件
            for (var x=0,xlen = this.files.length;x<xlen;x++) {
                file = this.files[x];
                // 对上传文件大小做限制 200kb
                if (file.size > 204800) {
                  swal("请上传.xlsx文件不要超过200KB！","","warning");
                  $("#uploadimg").val("");
                  return;
                }
            }
        });

      // 上传事件监听
      $("#submitbtn").click(function() {
          // 对不上传文件进行用户提示
          if ($("#uploadimg").val() == "") {
              swal("请上传一份小于200KB的.xlsx文件。","","warning");
              return;
          }
          var allFiles = document.querySelector("#uploadimg").files;
          // 实例化表单数据对象
          var formData = new FormData();
          // 遍历图片文件列表并插入至表单中
          for (var i=0,file;file = allFiles[i];i++) {
              // 包含文件名称和文件对象
              formData.append(file.name,file);
          }
          console.log(formData);
          // ajax请求，向数据库进行信息提交
          $.ajaxSetup ({
                     headers: {
                        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                    }
            });

          $.ajax({
              url: "<?php echo e(url('/admin/upload/readConstrExcel')); ?>",
              type: 'post',
              data: formData,
              processData: false,
              contentType: false, 
              success: function(res) {
                  if (res['res'] == 1) {
                      swal("上传教学建设记录成功！请到个人档案进行核对！","","success");
                  }else {
                      swal("上传失败！请联系管理员！","","warning");
                  }
              }
          });

      });
    });
</script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.'.getTheme(), array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>